package org.makcro.sms.services.chat.web.client.widgets.subscirbers;

import java.util.ArrayList;
import java.util.List;

import org.makcro.sms.services.chat.web.client.widgets.EntityListBase;
import org.makcro.sms.services.chat.web.shared.dto.SubscriberDto;

import com.extjs.gxt.ui.client.data.PagingLoadResult;
import com.extjs.gxt.ui.client.data.PagingLoader;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.google.gwt.i18n.client.DateTimeFormat;

public class SubscribersPanel extends EntityListBase<SubscriberDto> {

	public SubscribersPanel(PagingLoader<PagingLoadResult<SubscriberDto>> loader) {
		super( loader );
	}

	@Override
	public ColumnModel getColumnModel() {
		List<ColumnConfig> columns = new ArrayList<ColumnConfig>();

		ColumnConfig phoneColumn = new ColumnConfig( "phonenumber", "Broj telefona", 150 );

		ColumnConfig subscriptionDateColumn = new ColumnConfig( "subscriptionDate", "Vreme poslednje poruke", 150 );
		subscriptionDateColumn.setDateTimeFormat( DateTimeFormat.getFormat( "dd/MM/yyyy 'u' HH:mm" ) );

		ColumnConfig unsubscribedColumn = new ColumnConfig( "unsubscribed", "Odjavljen", 150 );
		unsubscribedColumn.setRenderer( new UnsubscribedGridCellRendererImpl() );

		ColumnConfig noteColumn = new ColumnConfig( "note", "Napomena", 150 );

		columns.add( phoneColumn );
		columns.add( subscriptionDateColumn );
		columns.add( unsubscribedColumn );
		columns.add( noteColumn );

		return new ColumnModel( columns );
	}

}
